package com.example.dao;


import com.example.pojo.Consult;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface ConsultCrudRepository extends CrudRepository<Consult, Integer>, JpaSpecificationExecutor<Consult> {
    //已配置列表
    @Query(value = "SELECT c from Consult c where c.agencyId =?1")
    List<Consult> selectedConsult(Integer agencyId);
    //未配置列表
    @Query("SELECT cc FROM Consult cc WHERE cc.agencyId = 0 AND NOT EXISTS (SELECT 1 FROM Consult c WHERE c.agencyId = ?1 AND c.question = cc.question AND c.answer = cc.answer)")
    List<Consult> unselectedConsult(Integer agencyId);
    @Query("SELECT c from Consult c where c.agencyId =?1 and c.status='已发布'")
    List<Consult> getConsultOfPublish(Integer agencyId);

    @Query("SELECT c from Consult c where c.userId =?1")
    List<Consult> getConsultOfMy(Integer id);
}
